#include"checksigtab.h"

#define SETBASICS ControllableBit rettab;\
   memset(&rettab,0,sizeof(rettab));\
   sigset_t sigset;\
   if(sigemptyset(&sigset))\
   {\
      rettab.errobit|=1;\
      rettab.signalbit|=(1<<SIGEMPTYSET);\
      return rettab;\
   }

#define CHECKMEM int signum=1;\
   while(signum<=31)\
   {\
      if(sigismember(&sigset,signum))\
      {\
         rettab.signalbit|=(1<<signum);\
      }\
      signum++;\
   }\
   return rettab;

namespace sigtabs{
ControllableBit GetBlockTab()
{
   SETBASICS;
   if(sigprocmask(SIG_BLOCK,nullptr,&sigset))
   {
      rettab.errobit|=1;
      rettab.signalbit|=(1<<SIGPROCMASK);
      return rettab;
   }
   CHECKMEM;
}
ControllableBit GetSiganlTab()
{
   SETBASICS;
   if(sigpending(&sigset))
   {
      rettab.errobit|=1;
      rettab.signalbit|=(1<<SIGPENDING);
      return rettab;
   }
   CHECKMEM;
}
}